package com.connection.second.web.controller.system;

import com.connection.second.common.constant.Constants;
import com.connection.second.common.core.domain.AjaxResult;
import com.connection.second.common.core.domain.model.LoginBody;
import com.connection.second.framework.security.handle.LogoutSuccessHandlerImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: FL
 * @Date: 2024/12/10 12:37
 **/
@RestController
public class SysLogoutController {
    @Autowired
    LogoutSuccessHandlerImpl logoutSuccessHandler ;
    /**
     * 登出方法
     *
     * @return 结果
     */
    @PostMapping("/logout")
    public AjaxResult logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException {
        AjaxResult ajax = AjaxResult.success();
        logoutSuccessHandler.onLogoutSuccess(request, response, authentication);
        return ajax;
    }
}
